package com.intellagric.agriecom.controller.agriecom_product;

import com.intellagric.agriecom.module.agriecom_merchant.MerchantService;
import com.intellagric.agriecom.module.agriecom_produce.ProduceService;
import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.module.agriecom.agriecom_produce.ParamValueVo;
import com.intellagric.pojo.AgriecomMerchant;
import com.intellagric.pojo.AgriecomProduce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.LinkedHashMap;
import java.util.List;


@Controller
public class ProductController {

    @Autowired
    private ProduceService produceService;
    @Autowired
    private MerchantService merchantService;

    @RequestMapping("/product/getProduce")
    @ResponseBody
    public AgriecomProduce getProduce(String productId){

        return produceService.queryProduceById(productId);
    }

    @RequestMapping("/product/getProduceList")
    @ResponseBody
    public LayuiDataGridResult getProduceList(int page,int limit,String categoryId){

        return produceService.getListByCategoryId(page,limit,categoryId);
    }

    @RequestMapping("/product/getMerchant")
    @ResponseBody
    public AgriecomMerchant getMerchant(String merchantId){

        return merchantService.getMerchantById(merchantId);
    }


    @RequestMapping("/product/getParamByCategoryId")
    @ResponseBody
    public List<ParamValueVo> getParamByCategoryId(String categoryId){

        return produceService.getParamByCategoryId(categoryId);
    }


    @RequestMapping("/product/getAncestorsByCategoryId")
    @ResponseBody
    public LinkedHashMap<String,String> getAncestorsByCategoryId(String categoryId){

        return produceService.getAncestorsByCategoryId(categoryId);
    }



}
